module UserDetailHelper

  def set_form_setting
    @page = {}
    @page["styles"] = ["modify.css"]
    @page["scripts"] = ["/js/jquery-1.4.2.min.js", "/js/jquery.validate.min.js"]
  end

  def getUserDetails userid
    connection = ActiveRecord::Base.connection
    #raise connection.inspect
        
    #Prepare SQL String
    strSQL = "SELECT * FROM ("
    strSQL += "SELECT     A.EmployeeNumber as 'samaccountName', A.Name as 'givenname', A.BusinessUnit as 'company', A.Department as 'department', A.JobTitle as 'jobtitle', A.PhoneWork as 'phonework' , A.PhoneCell AS 'mobile', A.EMail as 'mail', A.OfficeAddress as 'streetaddress', B.Name as 'manager', A.SkypeName as 'skypename', A.WikiSpaceURL as 'wikiurl', A.CubeLocation as 'cubelocation'"
    strSQL += " FROM         VW_Employee  A LEFT OUTER JOIN VW_Employee B ON (B.EmployeeNumber=A.Manager)"
    strSQL += " UNION"
    strSQL += " SELECT     '' AS 'samaccountName', RoomDisplayName AS 'givenName', '' AS 'company', '' AS 'department', '' AS 'jobtitle', PhoneNumber AS 'phonework', '' AS 'mobile', '' AS 'mail', OfficeName AS 'streetaddress', '' AS 'manager', '' AS 'skypename', '' AS 'wikiurl', '' AS 'cubelocation'"
    strSQL += " FROM         VW_Room"
    strSQL += " ) T"
    strSQL += " WHERE samaccountName='" + userid.to_s + "'"
        
    hash_set = connection.select_all strSQL
    @hash_set_details = ({"rows" => hash_set}).to_json
  end
end
